fix(ui,nextjs): use rsc client reference for clerk-ui instead of dynamic import#7809
fix(ui,nextjs): use rsc client reference for clerk-ui instead of dynamic import#7809jacekradko merged 3 commits intomainfrom
Conversation
…ic import The dynamic import of @clerk/ui/entry with webpackIgnore/turbopackIgnore pragmas caused bare module specifiers to reach the browser runtime, failing with "TypeError: Failed to resolve module specifier". Removing the pragmas caused build failures when @clerk/ui wasn't installed. Instead, mark ClerkUI.ts with 'use client' so the RSC bundler automatically serializes it as a client reference when imported from server.ts (react-server condition). The client resolves the reference on hydration without any dynamic import.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: d1d2372 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughClerkUI was converted into a client module with a "use client" entry re-export, and server-side 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/ui/src/entry.ts`:
- Line 3: The public export ClerkUI is undocumented; add a JSDoc comment
describing the exported API (either directly above the export in entry.ts or on
the ClerkUI class declaration) that states what ClerkUI is, its purpose, any
important props/options or constructor parameters, and any public methods/events
it exposes; ensure the JSDoc includes `@public` (or appropriate visibility tag)
and param/returns tags where applicable so the new ClerkUI export satisfies the
project’s public API documentation requirement.
|
!snapshot |
|
Hey @jacekradko - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.3.0-snapshot.v20260210034549 --save-exact
npm i @clerk/astro@3.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/backend@3.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/chrome-extension@3.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/clerk-js@6.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/dev-cli@1.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/expo@3.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/expo-passkeys@1.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/express@2.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/fastify@2.7.0-snapshot.v20260210034549 --save-exact
npm i @clerk/localizations@4.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/msw@0.0.1-snapshot.v20260210034549 --save-exact
npm i @clerk/nextjs@7.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/nuxt@2.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/react@6.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/react-router@3.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/shared@4.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/tanstack-react-start@1.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/testing@2.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/ui@1.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/upgrade@2.0.0-snapshot.v20260210034549 --save-exact
npm i @clerk/vue@2.0.0-snapshot.v20260210034549 --save-exact |
Align webpackChunkName for SignUp imports to "signup" (lowercase) to prevent case-sensitivity collision on Linux CI (signUp.js vs signup.js).
Summary
webpackIgnore/turbopackIgnoredynamic import of@clerk/ui/entryfrom Next.jsClerkProvider'use client'directive to@clerk/ui'sClerkUI.tsandentry.tsso RSC serializesClerkUIas a client referenceClerkUIin@clerk/ui's server export (server.ts) — the RSC bundler creates a client module reference instead of bundling the actual code on the serverProblem
The
import(/* webpackIgnore: true */ /* turbopackIgnore: true */ '@clerk/ui/entry')approach had two failure modes:@clerk/ui/entryin the browser bundle. Browsers cannot resolve bare module specifiers →TypeError: Failed to resolve module specifier '@clerk/ui/entry'@clerk/ui/entryat build time. Since@clerk/uiis an optional dependency, apps without it installed get a build failureSolution
Use RSC's built-in client reference mechanism:
ClerkUI.tsis marked with'use client'— this is semantically correct since it's client-only UI codeserver.ts(used via thereact-serverpackage.json condition) now includesClerkUIimported from./entryserver.ts, it sees the'use client'boundary onClerkUI.jsand creates a client module reference instead of including the actual codeClerkUIclass from the client bundleNo dynamic import needed. No bundler-specific workarounds. Works with both webpack and Turbopack.
Test plan
pnpm buildpasses for@clerk/uiand@clerk/nextjspnpm testpasses for@clerk/ui(1548 tests) and@clerk/nextjs(347 tests)dist/ClerkUI.jshas"use client"directivedist/server.jsimports from./ClerkUI.js(which has the client boundary)@clerk/ui/entrybare specifier in@clerk/nextjsbuilt outputSummary by CodeRabbit
New Features
Bug Fixes
Chores